package xworker.dataObject.data;

import org.xmeta.ActionContext;
import xworker.dataObject.data.tree.TreeModel;
import xworker.dataObject.data.tree.TreeModelListener;
import xworker.dataObject.*;

public class DefaultDataBinder implements DataBinder{
    @Override
    public boolean bind(Object source, Object target, String params, ActionContext actionContext) {
        if(source instanceof DataObject && target instanceof DataObjectListener){
            ((DataObject) source).addListener((DataObjectListener) target);
            return true;
        }else if(source instanceof DataStore && target instanceof DataStoreListener){
            ((DataStore) source).addListener((DataStoreListener) target);
            return true;
        }else if(source instanceof DataObjectList && target instanceof DataObjectListListener){
            ((DataObjectList) source).addListener((DataObjectListListener) target);
            return true;
        }else if(source instanceof TreeModel && target instanceof TreeModelListener){
            ((TreeModel) source).addListener((TreeModelListener) target);
            return true;
        }

        return false;
    }
}
